<template>
	<u-cell-group>
		<template v-for="(v, k) in baseInfo">
			<u-cell-item v-if="v.formType == 'customer'" :key="k" :arrow="false" :title="v.name" :value="v.value.customerName"></u-cell-item>
			<u-cell-item v-else-if="v.formType == 'business'" :key="k" :arrow="false" :title="v.name || '--'" :value="v.value.businessName"></u-cell-item>
			<u-cell-item v-else-if="v.formType == 'contacts'" :key="k" :arrow="false" :title="v.name" :value="v.value.contractsName || '--'"></u-cell-item>
			<u-cell-item v-else-if="v.formType == 'quotation'" :key="k" :arrow="false" :title="v.name" :value="v.value.quotationNumber || '--'"></u-cell-item>
			<u-cell-item v-else-if="v.formType == 'user'" :key="k" :arrow="false" :title="v.name" :value="v.value.join('、') || '--'"></u-cell-item>
			<u-cell-item v-else-if="v.formType == 'file'" :key="k" :arrow="false" :title="v.name" :value="v.value[0].name"></u-cell-item>
			<u-cell-item v-else :key="k" :arrow="false" :title="v.name" :value="v.value"></u-cell-item>
		</template>
	</u-cell-group>
</template>

<script>
export default {
	name: 'baseinfo',
	props: {
		id: {
			type: [String, Number],
			default() {
				return 5;
			},
		},
		type: {
			type: [String, Number],
			default() {
				return 0;
			},
		},
	},
	data() {
		return {
			baseInfo: {},
		};
	},
	mounted() {
		this.getBaseInfo();
	},
	methods: {
		// 获取基本信息
		async getBaseInfo() {
			let data = {
				types: this.type,
				id: this.id,
			};
			let res = await this.$api.customer.common.information(data);
			if (res.code === 200) {
				let list = res.data || [];
				this.baseInfo = list;
			}
		},
	},
};
</script>

<style lang="scss" scoped>
.baseinfo {
	height: 500px;
	overflow: auto;
}
</style>